package com.hardydou.system.service.impl;

import com.hardydou.system.mapper.SystemJobMapper;
import com.hardydou.system.model.SystemJob;
import com.hardydou.system.service.ISystemJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author ：hardy
 * @description：
 * @date ：Created in 2020-03-16
 * @Copyright ：Hardydou.com
 */
@Service
public class SystemJobServiceImpl implements ISystemJobService {

    @Autowired
    private SystemJobMapper jobMapper;

    @Override
    public int insert(SystemJob job) {
        job.setCtime(new Date());
        job.setUtime(job.getCtime());
        return jobMapper.insert(job);
    }

    @Override
    public int delete(Long jobId) {
        return jobMapper.deleteByPrimaryKey(jobId);
    }

    @Override
    public int update(SystemJob job) {
        job.setUtime(new Date());
        return jobMapper.updateByPrimaryKeySelective(job);

    }

    @Override
    public SystemJob find(Long jobId) {
        return jobMapper.selectByPrimaryKey(jobId);
    }

    @Override
    public List<SystemJob> find(Map params) {
        return jobMapper.list(params);
    }

    @Override
    public List<SystemJob> findByUserId(Long userId) {
        return jobMapper.selectByUserId(userId);
    }

    @Override
    public List<SystemJob> findAllByUserId(Long userId) {
        return jobMapper.selectAllByUserId(userId);
    }
}
